package com.createImg.createImg;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class GetHtmlContent {
	
	@SuppressWarnings("unused")
	public static void main(String[] args) throws Exception {
		String content = p("http://www.xzw.com/astro/gemini/");
		System.out.println(content);
	}
	
	public static String p(String url) throws MalformedURLException, IOException {
		
		String content = "";
	
		Document doc = Jsoup.parse(new URL(url),
				3000);
		
		Elements dt = doc.getElementsByTag("dt");
		
		Element ul = dt.get(1).getElementsByTag("ul").get(0);
		
		Elements li = ul.getElementsByTag("li");
		
		for (Element element : li) {
			String text = element.getElementsByTag("label").text();
			content=content+element.text().replaceAll(text, "")+"\n";
		}
		
		Element p = doc.getElementsByTag("dd").get(1).getElementsByTag("p")
				.get(0);
		
		content+=p.text();
		
		return content;
	}
}
